package day14.tarena.com;

public class Student implements Comparable{
	private int id;
	private String name;
	
	public Student(){
		super();
	}

	public Student(int id, String name){
		super();
		this.setId(id);
		this.setName(name);
		
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	//自然排序必须实现Comparable接口。
	public  int compareTo(Object obj){      
			if(obj == null) return 0;
			else if(obj instanceof Student){
				Student s = (Student)obj;
				System.out.println(this.id+":"+s.id);
				return this.id - s.id;
				//return name.compareTo(s.name);  怎么实现比较的？
			}return 0;
	}
	
	//public int comparator() 
	public String toString(){
		return id+":"+name;
	}

}
